#!/bin/bash
source experiment.cfg
echo "Starting controller instance"
aws ec2 run-instances --image-id $controller_image --count 1 --instance-type $instance_type --key-name $key_name --security-groups $security_groups | grep InstanceId | tr -cs 'a-zA-Z0-9.-' '[\n*]' | grep "i-" > $controller_instanceid_file
echo "Sleeping to let controller instance warm up"
sleep 5
echo "Saving controller's public DNS name"
aws ec2 describe-instances --instance-ids $(cat $controller_instanceid_file) | grep PublicDns | tr -cs 'a-zA-Z0-9.-' '[\n*]' | grep ec2 > $controller_dns_file
